home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / make / icmake-6.000 / icmake-6 / icmake / exec / push.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-08  |  1.6 KB  |  57 lines

  1. /*
  2. \funcref{push}{void push (\params)}
  3.     {
  4.         {VAR\_} {v} {variable to push}
  5.     }
  6.     {}
  7.     {xrealloc()}
  8.     {pop()}
  9.     {push.c}
  10.     {
  11.  
  12.         This function pushes a variable of the {\em VAR\_} struct type onto
  13.         the stack. The stack is relocatable and therefore grows upward. The
  14.         reallocation of the stack occurs in blocks of 10 elements.
  15.  
  16.         The stack is pointed to by {\em VAR\_ $*$stack}. The last used
  17.         element of the stack is indexed by {\em sp}. Therefore, {\em
  18.         stack[sp]} is the pushed value after {\em push()} completes.
  19.  
  20.         Each stack element contains the following fields:
  21.  
  22.         \begin{itemize}
  23.  
  24.             \item the variable type is defined in field {\em type}. The type
  25.             may be: {\em e\_int}, {\em e\_str} e\_list}. Other types, which are
  26.             used by the {\em icmake} compiler, have no meaning in the execution
  27.             phase.
  28.  
  29.             \item the variable value is kept in field {\em vu}. Depending on
  30.             the variable type, {\em vu$\rightarrow$ls.str} is a pointer to an
  31.             allocated string, {\em vu.intval} is an integer value, {\em
  32.             vu$\rightarrow$ls.list} is a list.
  33.  
  34.             A list variable contains a {\em size} field, stating the number of
  35.             elements in the list, and an {\em element} field which is a {\em
  36.             char $**$}.
  37.  
  38.         \end{itemize}
  39.     }
  40. */
  41.  
  42. #include "icm-exec.h"
  43.  
  44. static unsigned
  45.     stacksize;
  46.  
  47. void push (VAR_ v)
  48. {
  49.     sp++;
  50.     if (stacksize <= sp)
  51.     {
  52.         stacksize = sp + 10;
  53.         stack = xrealloc (stack, stacksize * sizeof (VAR_));
  54.     }
  55.     stack [sp] = v;
  56. }
  57.